/****************************************Copyright (c)****************************************************
 
**--------------File Info---------------------------------------------------------------------------------
** File name:                at32f415_int.c
** Last modified Date:       2024.08.07
** Last Version:             Ver:1.0
** Descriptions:             
**                        
**--------------------------------------------------------------------------------------------------------
** Created by:               adm
** Created date:             2024.08.07
** Version:                  Ver:1.0
** Descriptions:             
**--------------------------------------------------------------------------------------------------------*/

/* includes ------------------------------------------------------------------*/
#include "at32f415_int.h"
#include "at32f415_wk_config.h"
#include "at32f415_board.h"

/**
  * @brief  this function handles nmi exception.
  * @param  none
  * @retval none
  */
void NMI_Handler(void)
{
    
}

/**
  * @brief  this function handles hard fault exception.
  * @param  none
  * @retval none
  */
void HardFault_Handler(void)
{
    while (1) {
        
    }
}

/**
  * @brief  this function handles memory manage exception.
  * @param  none
  * @retval none
  */
void MemManage_Handler(void)
{
    while (1) {
        
    }
}

/**
  * @brief  this function handles bus fault exception.
  * @param  none
  * @retval none
  */
void BusFault_Handler(void)
{
    while (1) {
        
    }
}

/**
  * @brief  this function handles usage fault exception.
  * @param  none
  * @retval none
  */
void UsageFault_Handler(void)
{
    while (1) {
        
    }
}

/**
  * @brief  this function handles svcall exception.
  * @param  none
  * @retval none
  */
//void SVC_Handler(void)
//{
//    
//}

/**
  * @brief  this function handles debug monitor exception.
  * @param  none
  * @retval none
  */
void DebugMon_Handler(void)
{
    
}

/**
  * @brief  this function handles pendsv_handler exception.
  * @param  none
  * @retval none
  */
//void PendSV_Handler(void)
//{
//    
//}

/**
  * @brief  this function handles systick handler.
  * @param  none
  * @retval none
  */
//void SysTick_Handler(void)
//{
//    
//}

/**
  * @brief  this function handles TMR1 Trigger and hall and TMR11 handler.
  * @param  none
  * @retval none
  */
void TMR1_TRG_HALL_TMR11_IRQHandler(void)
{
    static uint8_t count_10ms = 0;
    
    if(tmr_interrupt_flag_get(TMR11, TMR_OVF_FLAG) != RESET)
      {
        /* add user code... */
        ms_count--;                         // delay_ms延时处理
    
        KeyCheckFun();                      // 电键检测状态机进程
        
        if(count_10ms >= 10) {              // 每10ms运行一次按钮状态机
            count_10ms = 0;
            button_ticks();                 // 按键时基函数
        }
        
        count_10ms++;
    
        tmr_flag_clear(TMR11, TMR_OVF_FLAG);
      }
}


